package com.game.demo409.demo409;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;


import de.keyboardsurfer.android.widget.crouton.Configuration;
import de.keyboardsurfer.android.widget.crouton.Crouton;
import de.keyboardsurfer.android.widget.crouton.Style;
import widget.CheckBox;
import com.rengwuxian.materialedittext.MaterialEditText;

public class LoginActivity extends Activity implements View.OnClickListener{

    private Button mSignBtn;
    private Button mSignUp;
    private MaterialEditText mUsernameEdt;
    private MaterialEditText mPasswordEdt;
    private TextView mFogetted_password;
    private CheckBox mRemember;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);
        mUsernameEdt = (MaterialEditText)findViewById(R.id.edit_username);
        mPasswordEdt = (MaterialEditText)findViewById(R.id.edit_password);
        mSignBtn = (Button)findViewById(R.id.btnSignIn);
        mSignUp = (Button)findViewById(R.id.btnSignUp);
        mFogetted_password = (TextView)findViewById(R.id.fogeted_password);

        mSignBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //TODO
                String str_username = mUsernameEdt.getText().toString().trim();
                String str_password = mPasswordEdt.getText().toString().trim();
                System.out.println(str_username+"  "+str_password);
                if(str_username.equals("admin")&&str_password.equals("123456")) {
                    Intent intent = new Intent(LoginActivity.this, com.game.demo409.demo409.MainActivity.class);
                    startActivity(intent);
                    //finish();
                }
                else {
                    final Crouton crouton;
                    crouton  =  Crouton.makeText(LoginActivity.this,"账号或者密码错误",Style.ALERT);
                    crouton.setConfiguration(new Configuration.Builder().setDuration(Configuration.DURATION_SHORT).build());
                    crouton.show();

                }
            }
        });

        mSignUp.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //TODO
                Intent intent = new Intent(LoginActivity.this, com.game.demo409.demo409.SignUpActivity.class);
                startActivity(intent);
            }
        });
        mFogetted_password.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //TODO
            }
        });

    }


    @Override
    public void onClick(View v) {
       //TODO

    }
}
